﻿using System;

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]
namespace P2P.Main.Util
{
    public class Logger
    {
        private static readonly log4net.ILog logInfo = log4net.LogManager.GetLogger("logInfo");
        private static readonly log4net.ILog logError = log4net.LogManager.GetLogger("logError");
        private static readonly log4net.ILog logWarning = log4net.LogManager.GetLogger("logWarning");

        public static void WriteInfo(string info)
        {
            Console.WriteLine(info);
            if (logInfo.IsInfoEnabled)
            {
                logInfo.Info(info);
            }
        }

        public static void WriteError(string error)
        {
            Console.WriteLine(error);
            if (logError.IsErrorEnabled)
            {
                logError.Error(error);
            }
        }

        public static void WriteError(string error, Exception ex)
        {   
            Console.WriteLine(error);
            if (logError.IsErrorEnabled)
            {
                logError.Error(error, ex);
            }
        }

        public static void WriteWarning(string warning)
        {   
            Console.WriteLine(warning);
            if (logWarning.IsWarnEnabled)
            {
                logWarning.Warn(warning);
            }
        }
    }
}
